package com.lin.demo.one2many.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.lin.demo.one2many.po.Dept;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
@DS("one2many")
public interface DeptMapper {
    @Select("select * from dept;")
    List<Dept> getAllDept();

    @Select("select * from dept where deptid=#{deptId}")
    @Results({
            @Result(id = true, column = "deptid", property = "DeptId"),
            @Result(column = "deptid", property = "userList",
                    one = @One(select = "com.lin.demo.one2many.mapper.UserMapper.getUserListByDeptId"))
        }
    )
    Dept getDeptById(Integer DeptId);
}
